# while True: print('hello world')
"""
while True:
    try:
        x = int(input("Enter a number:"))
        break
    except (ValueError , TypeError , NameError):
        print("Oops! that was no valid number. try again...F")
class B(Exception):
    pass
class C(B):
    pass
class D(C):
    pass
for cls in [B,C,D]:
    try:
        raise cls()
    except D:
        print("D")
    except C:
        print("C")
    except B:
        print("B")

"""
"""

try:
    raise Exception('spam' , 'eggs')
except Exception as inst:
    print(type(inst))
    print(inst.args)
    print(inst)
    x , y = inst.args
    print('x=' , x)
    print('y=',y)
"""

import sys
"""
try:
    f = open('D:\\test\\test.txt')
    s = f.readline()
    i = int(s.strip())
except OSError as err:
    print(err)
except  ValueError:
    print("could not convert data to an inteager.")
except Exception as err:
    print(f"Unexpected {err=} , {type(err)=}")

for arg in sys.argv[1:]:
    try:
        f = open(arg , 'r')
    except OSError as err:
        print("Cannot open " , arg)
    else:
        print(arg , "has" , len(f.readlines()) , 'lines')
        f.close()
        
        
"""
"""
def this_fails():
    x = 1/0
try:
    this_fails()
except ZeroDivisionError as err:
    print("Handing run-time error:" , err)
try:
    raise NameError('hi there')
except NameError:
    print("an exception flew by !")
    raise 
"""
# print("===**"*20)
# try:
#     open("database.sqlite")
# except OSError:
#     raise RuntimeError("unable to handler error")

# def func():
#     raise ConnectionError
# try:
#     func()
# except ConnectionError as exc:
#     raise RuntimeError("Failed to open database") from exc
# try:
#     open("database.sqlite")
# except OSError:
#     raise RuntimeError from None

# try:
#     raise KeyboardInterrupt
# finally:
#     print("Goodbye , world")
# def divide(x,y):
#     try:
#         result = x  / y
#     except ZeroDivisionError :
#         print("didvision by zero ")
#     else:
#         print("result is " , result)
#     finally:
#         print("executing finally clause")
# divide(2,1)

# for line in open("myfile.tzt"):
#     print(line , end="")
# with open("D:\\test\\test.txt") as f:
#     for line in f.readlines():
#         print(line , end="")

# with open("D:\\test\\test.txt") as f:
#     for line in f:
#         print(line , end="")

def  f():
    excs = [OSError("Error 1") , SystemError("Erorr2")]
    raise ExceptionGroup("there were  problems " , excs)
f()